package com.xdcplus.web.controller.test;


import com.xdcplus.exceptions.domain.ResponseVO;
import com.xdcplus.mom.controller.AbstractController;
import com.xdcplus.web.handler.PacketTraceWashHandler;
import com.xdcplus.web.service.DataService;
import io.minio.errors.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

@Api(tags = "数据处理")
@Slf4j
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("data")
public class DataController extends AbstractController {

    @Autowired
    protected DataService dataService;

    @ApiOperation("车间产量")
    @GetMapping(value = "/factory/produce", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO getPrdInfoTrace(@RequestParam("date") String date) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
        return ResponseVO.success(dataService.getFactoryProduce(date));
    }

    @ApiOperation("效率推移")
    @GetMapping(value = "/eff", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO getEff(@RequestParam("date") String date, @RequestParam("spec") String spec) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
        return ResponseVO.success(dataService.getFactoryProduce(date + "-" + spec));
    }


}
